<?php
/**
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; version 3 of the License.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
*/

/**
 * Helper for Google Analitics code injection.
 * @package Core
 * @subpackage View.Helper
 * @category Helper
 * @author Vincze Tamás
 */
namespace Core\View\Helper;

class GoogleAnalytics extends Helper
{
	/**
	 * text of title
	 * @access proetcted
	 * @var string
	 */
	protected $_text;

    /**
     * Constructor.
     * @access public
     * @param string $text The title string.
     * @return void
     */
    public function __construct($analyticsCode)
    {
		$this->_text = (string)$analyticsCode;
    }

	/**
	 * Returns with helper string.
	 * @access public
	 * @return string
	 */
	public function getHelper()
	{
		return "<script type='text/javascript'>
		  var _gaq = _gaq || [];
		  _gaq.push(['_setAccount', '".$this->_text."']);
		  _gaq.push(['_trackPageview']);
		  (function() {
			var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
			ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
			var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
		  })();
		</script>";
	}
    
}